package com.google.code.opencode.action;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.code.opencode.dao.FeedDao;
import com.google.code.opencode.model.Feed;
import com.opensymphony.xwork2.ActionSupport;

public class AddFeed extends ActionSupport {

	private static final long serialVersionUID = -4129263138184074823L;
	private static final Logger logger = LoggerFactory.getLogger(AddFeed.class);

	private FeedDao feedDao;

	public Feed feed;

	public AddFeed(FeedDao feedDao) {
		this.feedDao = feedDao;
	}

	public String execute() throws Exception {
		logger.debug("About to add the information about a feed.");

		feed.setLastPublishedDate(new Date());
		feed.setLastPublishedStatus("");
		feedDao.create(feed);

		logger.debug("Finished adding the information about the feed.");

		return SUCCESS;
	}

	public Feed getFeed() {
		return feed;
	}

	public void setFeed(Feed feed) {
		this.feed = feed;
	}

}
